home *** CD-ROM | disk | FTP | other *** search
- /*
- 11-11-92 • BRS changed things from short to long, to fix bug with THINK C compiler.
-
-
-
- */
- #include "DirectScreen.h"
-
- void DirectPlotColorIcon(long *colorIconPtr, PixMapHandle screenPixMap, short row, short col)
- /*
- Draws a color icon image directly to the pixMap passed.
- colorIconPtr = pointer to the image data for a color icon
- screenPixMap = handle to the pixMap for the screen we're writing on
- row, col = location of the top left corner of the icon in the
- pixMap's coordinate system;
- since we know the icon is 32 by 32,
- the other coordinates are unnecessary.
- */
- {
- register long *screenMemPtr; // Pointer to video memory
- register long numRowsToCopy; // Rows we are going to copy
- register long stripRowBytes; // To clear high bit of rowbytes
- register long rowLongsOffset; // rowBytes converted to long
- char mmuMode; // 32-bit mode required
- Rect cursRect; // rectangle for shield cursor call
- Point cursOffset; // 0,0 to indicate rect is in global coordinates
-
- /* High bit of pixMap rowBytes must be cleared. */
- stripRowBytes = (0x7FFF & (**screenPixMap).rowBytes);
-
- /* We must strip the high byte of the address of the color icon, which, if we're in
- 24-bit mode, may be garbage when we go to 32-bit mode to access video memory. */
- colorIconPtr = (long *)StripAddress(colorIconPtr);
-
- /* Calculate the address of the first byte of the destination. */
- // screenMemPtr = (long *)(GetPixBaseAddr(screenPixMap) + (stripRowBytes * row) + col);
- // Avoid the trap overhead of GetPixBaseAddr - which is also known to cause problems
- screenMemPtr = (long *)((**screenPixMap).baseAddr + (stripRowBytes * row) + col);
-
- /* call shield cursor to maintain compatibility with all displays */
- /* This rectangle should be a parameter, but this was added to late */
- cursOffset.h = 0;
- cursOffset.v = 0;
- cursRect.top = row;
- cursRect.left = col;
- cursRect.bottom = row + 32;
- cursRect.right = col + 32;
- ShieldCursor(&cursRect,cursOffset);
-
- /* Change to 32-bit addressing mode to access video memory. The previous addressing mode
- is returned in mmuMode for restoring later. */
- mmuMode = true32b;
- SwapMMUMode(&mmuMode);
-
- numRowsToCopy = 32; /* Color icons have 32 rows. */
-
- /* Calculate the long word offset from the end of one row of the color icon on the screen's
- pixMap to the first byte of the icon in the next row. */
- rowLongsOffset = (stripRowBytes/4) - 8;
-
- /* Draw the color icon directly to the screen. */
- do {
- *screenMemPtr++ = *colorIconPtr++;
- *screenMemPtr++ = *colorIconPtr++;
- *screenMemPtr++ = *colorIconPtr++;
- *screenMemPtr++ = *colorIconPtr++;
- *screenMemPtr++ = *colorIconPtr++;
- *screenMemPtr++ = *colorIconPtr++;
- *screenMemPtr++ = *colorIconPtr++;
- *screenMemPtr++ = *colorIconPtr++;
-
- /* Bump to start of next row. */
- screenMemPtr += rowLongsOffset;
- } while(--numRowsToCopy);
-
-
- SwapMMUMode(&mmuMode); /* Restore addressing mode back to what it was. */
- ShowCursor();
- }
-